package lvm.fonctions.prim.fsubr;

import lvm.Contexte;
import lvm.LvmException;
import lvm.struct.Sexpr;
import lvm.struct.Symbole;

public class Set extends Fsubr {

	public static final Set SET = new Set();
	
	public Set() {
		super("set");
	}

	@Override
	public Sexpr exec(Sexpr arg) throws LvmException {
		
		if((arg.getCar() instanceof Symbole)&&(arg.getCdr().getCar() instanceof Symbole )){
			Contexte.getContexteCourant().putVariable(arg.getCar().toString(),new Symbole(arg.getCdr().getCar().toString()));
			return new Symbole(arg.getCar().toString()+" = "+arg.getCdr().getCar().toString());
		}else{
			return new Symbole("Argument non reconu");
		}
		
	}

}
